package javacafe.action.studybbs;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javacafe.action.Action;
import javacafe.action.ActionForward;
import javacafe.dto.member.LoginInfoDTO;
import javacafe.dto.study.StudyDTO;
import javacafe.dto.study.StudyMemberDTO;
import javacafe.dto.studybbs.StudyBBSDTO;
import javacafe.dto.studybbs.StudyBBSReplyDTO;
import javacafe.dto.studybbs.StudyPostDTO;
import javacafe.service.StudyBBSService;
import javacafe.service.StudyMemberService;
import javacafe.service.StudyService;
import javacafe.serviceimple.StudyBBSServiceImpl;
import javacafe.serviceimple.StudyMemberServiceImpl;
import javacafe.serviceimple.StudyServiceImpl;

public class InsertReplyAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		int sp_no = Integer.parseInt( request.getParameter("sp_no") );
		int study_no = Integer.parseInt(request.getParameter("study_no"));
		int m_no = ((LoginInfoDTO)request.getSession().getAttribute("loginInfo")).getM_no();
		int sbbs_no = Integer.parseInt(request.getParameter("sbbs_no"));
		String sbr_content = request.getParameter("sbr_content");
		
		StudyBBSService studyBBSService = StudyBBSServiceImpl.getInstance();
		StudyBBSReplyDTO replyDTO = new StudyBBSReplyDTO();
		replyDTO.setSp_no(sp_no);
		replyDTO.setM_no(m_no);
		replyDTO.setSbr_content(sbr_content);
		replyDTO.setStudy_no(study_no);
		replyDTO.setSbbs_no(sbbs_no);
		
		studyBBSService.insertReply(replyDTO);
		
		ActionForward forward = new ActionForward();
		forward.setUrl("readstudypost");
				
		return forward;
	}

}
